#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    //使用纯代码的方式，创建按钮版本的Hello World!!!
    //myButtono需要设置为成员变量
    myButton = new QPushButton(this);

    myButton->setText("Hello World!!!");

    //设置点击事件
    connect(myButton, &QPushButton::clicked, this, &Widget::handleClick);
}

Widget::~Widget()
{
    delete ui;
}

void Widget::handleClick()
{
    if(myButton->text() == QString("Hello World!!!"))
    {
        myButton->setText("Hello QT!!!");
    }
    else
    {
        myButton->setText("Hello World!!!");
    }
}
